package GameLogic;

public class EnemyElfMage extends EntityEnemy{

	private double startingY;
	private double xThreshold;
	public EnemyElfMage()
	{
		health = 10;
		movementVelocity = 0.0001f;
		model = new EntityModel();
		value = 20;
		attackProbability = 0.15f;
		startingY = Math.random()/2; 
		model.texture_path = "res/ElfMage.png";
		
		 model.frames=1;                            //model does not have any frames
	        model.texture_coordinates=new float[] {0.0f, 0.0f,      //quad vertices; NOTICE: if you start with 0 as bottom left vertex
	                                     0.0f, 1.0f,       // it will spin around this vertex (rotate is performed on 0,0)
	                                     1.0f, 1.0f,
	                                     1.0f, 0.0f};
	        model.vertex_colour = new float[] {0.0f, 0.0f, 0.0f, 1.0f,  //RGBA, each vertex of quad
	                                        0.0f, 0.0f, 0.0f, 1.0f,
	                                        0.0f, 0.0f, 0.0f, 1.0f,
	                                        0.0f, 0.0f, 0.0f, 1.0f};
	         model.vertices = new float[] {-0.125f, -0.125f,      //quad vertices; NOTICE: if you start with 0 as bottom left vertex
	                                     0.125f, -0.125f,       // it will spin around this vertex (rotate is performed on 0,0)
	                                     0.125f, 0.125f,
	                                     -0.125f, 0.125f};
	         eCoord.scaleX = 0.75f;
	         eCoord.scaleY = 0.75f;
	         
	    xThreshold = 1.1+(Math.random()/3);
	}
	
	public void tick()
	{
		super.tick();
		updateMovementByPath();
		if(attackProbability < 1.0f)
		{
			attackProbability += 0.0001f;
		}
	}
	
	public boolean isAttacking()
	{
		double random = Math.random();
		return random<attackProbability;
	}
	
	@Override
	void updateMovementByPath() {
		eCoord.posY = startingY + Math.pow((Math.sin(timeExisted*3)), 2)/1.5f;
		if(eCoord.posX > xThreshold)
		{
			eCoord.posX -= movementVelocity*85;
		}else
		{
			//eCoord.posX = xThreshold + Math.pow((Math.cos(timeExisted*3)), 2)/1.5f;
		}
	}

	@Override
	void attack() {
		// TODO Auto-generated method stub
		model.vertex_colour[3] -= Math.sin(timeExisted*5);
		attackProbability = 0;
	}

}
